package com.job.tencent;

import java.util.Scanner;

/**
 * @ClassName: test.Tencent3
 * @Description:
 * @Author: 12071
 * @Date: 2022/4/24 20:45
 */
public class Tencent3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        char[] a = sc.nextLine().toCharArray();
        int left =0, right=0;
        for (int i = 0; i < a.length; i++) {
            if(a[i]=='1')
                right +=(i+1);
        }
        int min = right;
        for (int i = 0; i < a.length; i++) {
            if(a[i]=='0')
                left+=(i+1);
            else
                right-=(i+1);
            min = Math.min(min, Math.abs(left-right));
        }
        System.out.println(min);
    }
}
